{%include file="../public/top.html"%}

<div id="content-header">
    <h1>激活码管理</h1>
    <div class="btn-group">
        <button class="btn btn-primary btn-large add_code" data-url="/invit_code/add_code">生成激活码</button>
    </div>
</div>
<div id="breadcrumb">
    <a href="#" title="Go to Home" class="tip-bottom"><i class="icon-home"></i> 首页</a>
    <a href="#" class="current">激活码管理</a>
</div>
<div class="container-fluid">
    <div class="row-fluid">
        <div class="span12">
            <div class="widget-box">
                <div class="widget-title">
								<span class="icon">
									<i class="icon-th"></i>
								</span>
                    <h5>激活码列表</h5>
                </div>
                <div class="widget-content nopadding">
                    <table class="table table-bordered table-striped">
                        <thead>
                        <tr>
                            <th style="color: red;">ID</th>
                            <th style="color: red;">用户名</th>
                            <th style="color: red;">微信ID</th>
                            <th style="color: red;">关注时间</th>
                            <th style="color: red;">取消关注时间</th>
                            <th style="color: red;">状态</th>
                            <th style="color: red;">操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        {%foreach from=$user_data item=data%}
                        <tr>
                            <td style="text-align: center;">{%$data.id%}</td>
                            <td style="text-align: center;">{%$data.nickname%}</td>
                            <td style="text-align: center;">{%$data.openid%}</td>
                            <td style="text-align: center;">{%date('Y-m-d H:i:s',$data.create_time)%}</td>
                            <td style="text-align: center;">{%if $data.status != 2%}暂无{%else%}{%date('Y-m-d H:i:s',$data.close_time)%}{%/if%}</td>
                            <td style="text-align: center;">{%replace_user_status($data.status)%}</td>
                            <td style="text-align: center;">{%if $data.status == 2%}<button data-id="{%$data.id%}" data-url="/user/opera_status" class="btn btn-success cancel_dis">取消禁用</button>{%else%}<button data-id="{%$data.id%}" data-url="/user/opera_status" class="btn btn-danger dis_user">禁用</button>{%/if%}</td>
                        </tr>
                        {%/foreach%}
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
{%include file="../public/bottom.html"%}
    <script>
        $('.dis_user').on('click',function(){
            var url = $(this).data('url');
            var id = $(this).data('id');
            $.ajax({
                url : url,
                data:{'id':id,'action':'dis'},
                type: 'post',
                dataType:'json',
                success:function(result){
                    if(result.code !== 200){
                        alert(result.message);
                        return;
                    }else{
                        alert(result.message);
                        window.location.reload();
                    }
                }
            });
        });
        $('.cancel_dis').on('click',function(){
            var url = $(this).data('url');
            var id = $(this).data('id');
            $.ajax({
                url : url,
                data:{'id':id,'action':'cancel'},
                type: 'post',
                dataType:'json',
                success:function(result){
                    if(result.code !== 200){
                        alert(result.message);
                        return;
                    }else{
                        alert(result.message);
                        window.location.reload();
                    }
                }
            });
        });
    </script>